"use strict";
angular.module('app.granaryInfo').controller('GranaryinfoCtrl', function($scope,HTTPDataService,Auths){
  
  if(!Auths.getUser())
    {
         window.location.href=baseurls+"#/login";
    } 

    $scope.user = Auths.getUser();
    $scope.selectPanelShow = false;

    if($scope.user.role == "head")
      {
        $scope.selectPanelShow =  true; 
      }
   
    
  /*  HTTPDataService.getGranaryInfo().then(function(response) {
           $scope.granaryData = response;
      
      });*/
  
   //配置分页基本参数
        $scope.paginationConf = {
            currentPage: 1,
            itemsPerPage: 10,
            pagesLength: 5,
            totalItems:20,
            perPageOptions: [10, 20, 30, 40, 50],
            onChange: function(){
            }
        };

        
     var GetAllEmployee = function () {
 
          HTTPDataService.getGranaryInfo($scope.paginationConf).then(function (response) {
               
                $scope.paginationConf.totalItems = response['sum'];
                $scope.granaryData = response['content'];

            });
 
        }
 
        $scope.$watch('paginationConf.currentPage + paginationConf.itemsPerPage', GetAllEmployee);


 
  HTTPDataService.getSystemConfig().then(function(response){
       
        $scope.systemDate = response;
    });

  });